package com.breakfast.fun.ui.user.help;

import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.breakfast.fun.R;
import com.breakfast.fun.base.BaseActivity;
import com.breakfast.fun.base.BaseModel;
import com.breakfast.fun.base.BasePresenter;
import com.breakfast.fun.view.widget.TitleBarView;

import butterknife.Bind;

public class HelpContentActivity extends BaseActivity<BasePresenter, BaseModel> {

    @Bind(R.id.tbv_help_center_content)
    TitleBarView tbvHelpCenterContent;
    @Bind(R.id.wb_help_center_content)
    WebView wbHelpCenterContent;

    private String url;

    private WebViewClient webViewClient = new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            //页面加载完成了
            hideLoadingDialog();
        }
    };

    @Override
    public int getLayoutId() {
        return R.layout.activity_help_content;
    }

    @Override
    public void initView() {

        tbvHelpCenterContent.setTitleNoRight("问题详情");
        tbvHelpCenterContent.setBack(this);

        url = getIntent().getStringExtra("url");

        wbHelpCenterContent.setWebViewClient(webViewClient);

        //允许运行脚本语言
        WebSettings settings = wbHelpCenterContent.getSettings();
        settings.setJavaScriptEnabled(true);

        showLoadingDialog(true);
        wbHelpCenterContent.loadUrl(url);
    }
}
